import httpRequeset from "@/common/httpRequest.js"
const imgUrl = "https://hongnwh-1318979827.cos.ap-shanghai.myqcloud.com";
// 年月日时分秒
const date = (data, type) => {
	let time = new Date(data * 1000);
	let year = time.getFullYear();
	let month = time.getMonth() + 1;
	month = month < 10 ? '0' + month : month
	let day = time.getDate();
	day = day < 10 ? '0' + day : day
	let hours = time.getHours();
	hours = hours < 10 ? '0' + hours : hours
	let minute = time.getMinutes();
	minute = minute < 10 ? '0' + minute : minute
	let second = time.getSeconds();
	second = second < 10 ? '0' + second : second
	if (type == 1) {
		return year + '-' + month + '-' + day
	} else {
		return year + '-' + month + '-' + day + ' ' + hours + ':' + minute + ':' + second
	}
}
// 加载初始化
const initApp = async () => {
	const platform = uni.getSystemInfoSync().platform;
	let res = await httpRequeset.request("/api/common/init", "GET", {
		appform: 1,
		version: uni.getStorageSync("version"),
		platform: platform
	})
	return res
}
export default {
	install: (Vue, options) => {
		Vue.prototype.imgUrl = imgUrl;
		Vue.prototype.date = date
		Vue.prototype.initApp = initApp
	}
}